function weblink(value){
	if(value != ""){
		window.open(value);
	}
}

function getsubcat(div,base_url,id){
	http.open("get",base_url+"action.php?act=getsubcat&id="+id,true);
	http.onreadystatechange=function(){
			if(http.readyState==4 && http.status==200){
				var kq = http.responseText;
				if(kq == 0){
					document.getElementById(div).innerHTML = "Error";
				}else{
					document.getElementById(div).innerHTML = kq;
				}
			}
		};
	http.send("null");
}

/* xu ly gui comment */
function postcomment() {
	var fullname = encodeURI(document.getElementById('fullname').value);
	var email = encodeURI(document.getElementById('email').value);
	var tieude = encodeURI(document.getElementById('tieude').value);
	var maxacnhan = encodeURI(document.getElementById('maxacnhan').value);
	var noidung = encodeURI(document.getElementById('noidung').value);
	var idproduct = encodeURI(document.getElementById('idproduct').value);
	var base_url = encodeURI(document.getElementById('base_url').value);
	
	document.getElementById('report_post').innerHTML = "<img src = '"+base_url+"/public/template/images/ajax-loader.gif' />";
	nocache = Math.random();
	http.open('post', base_url+'action.php?act=addcomment&nocache='+nocache,true); 
	http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded;charset=UTF-8;');
	http.onreadystatechange = function(){
		if(http.readyState == 4 && http.status == 200){ 
			var response = http.responseText;
			if(response != 0){
				document.getElementById('report_post').innerHTML = response;
			} else {
				document.getElementById('report_post').innerHTML = '';
				document.getElementById('fullname').value = '';
				document.getElementById('email').value = '';
				document.getElementById('tieude').value = '';
				document.getElementById('maxacnhan').value = '';
				document.getElementById('noidung').value = '';
				alert('Gửi thành công. Cám ơn bạn đã góp ý cho sản phẩm này');
			}
		}
	};
	http.send('idproduct='+idproduct+'&fullname='+fullname+'&email='+email+'&tieude='+tieude+'&maxacnhan='+maxacnhan+'&noidung='+noidung);
}
